package com.health.fragment.focusgroup.child;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import com.health.viewscontrols.FWMYDPJActivity;
import com.health.viewscontrols.NovaApplication;
import com.health.viewscontrols.PersonalFileActivity.onFragmentSave;
import com.health.R;
import com.health.adapter.CheckBoxAdapter;
import com.health.adapter.RadioButtonAdapter;
import com.health.db.FDbManager;
import com.health.viewscontrols.focusgroup.ChildActivity;
import com.health.fragment.NovaFragment;
import com.health.tablebean.ARCHIVE_BASEINFO;
import com.health.tablebean.BD_DD_INFO;
import com.health.tablebean.CHILD_BASEINFO;
import com.health.tablebean.CHILD_NEWBORN_FOLLOWUP;
import com.health.tools.GlobalConts;
import com.health.view.spinner.NiceSpinner;
import com.health.widget.EditTextWithDate;
import com.health.widget.MyGridView;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;

/**
 * 新生儿访视 CHILD_NEWBORN_FOLLOWUP
 *
 * @author 鹿云龙
 */
public class XinShengErFangShiFragment extends NovaFragment implements onFragmentSave {
	private final static int I_NULL = -1;
	private View baseView = null;
	private static ARCHIVE_BASEINFO userInfo;// 基本信息
	// private MyGridView mgvMqsfzh;// 母亲身份证号
	private EditText et_xingming;
	private EditText et_shenfenzhenghao;
	/** 母亲妊娠期患病情况 */
	private NiceSpinner ns_mqrsqhbqk;
	private EditText et_mqrsqhbqk;
	private static FDbManager fdbmanger = null;
	private String IDCARD;
	/*** 无、有 */
	private List<BD_DD_INFO> lstWY;
	/** 未见异常 */
	private List<BD_DD_INFO> lstyc;
	/** 新生儿窒息 */
	private MyGridView mgv_xsrzx;
	private RadioButtonAdapter rba_xsrzx;
	/** apgar评分 */
	private MyGridView mgv_Apgar;
	private RadioButtonAdapter rba_Apgar;
	/** 出生情况 */
	private MyGridView mgv_csqk;
	private RadioButtonAdapter cba_csqk;
	// private EditText et_csqk;
	/** 是否有畸形 */
	private MyGridView mgv_sfyjx;
	/** 新生儿听力筛查 */
	private MyGridView mgv_xsrtlsc;
	/** 新生儿疾病筛查 */
	private MyGridView mgv_xsrjbsc;
	/** 新生儿喂养方式 */
	private MyGridView mgv_xsrwyfs;
	private RadioButtonAdapter rba_xsrwyfs;
	/** 吃奶量 */
	private EditText et_cnl;
	/** 大便 */
	private MyGridView dabian;
	/** 呕吐 */
	private MyGridView otu;
	/** 面色 */
	private MyGridView mgv_mianse;
	/** 黄疸 */
	private MyGridView mgv_huangdan;
	private RadioButtonAdapter rba_huangdan;
	/** 前囟 */
	private NiceSpinner ns_qianxin;

	/** 眼外观 */
	private MyGridView mgv_ywg;
	private RadioButtonAdapter rbaywg;
	private EditText et_ywg;
	/** 耳外观 */
	private MyGridView mgv_rwg;
	private RadioButtonAdapter rbarwg;
	private EditText et_rwg;
	/** 鼻 */
	private MyGridView mgv_bi;
	private RadioButtonAdapter rbabi;
	private EditText et_bi;
	/** 口腔 */
	private MyGridView mgv_kq;
	private RadioButtonAdapter rbakq;
	private EditText et_kq;
	/** 心肺听诊 */
	private MyGridView mgv_xftz;
	private RadioButtonAdapter rbaxftz;
	private EditText et_xftz;
	/** 腹部触诊 */
	private MyGridView mgv_fbcz;
	private RadioButtonAdapter rbaABDOMINAL_TOUCH;
	private EditText et_fbcz;
	/** 四肢活动度 */
	private MyGridView mgv_szhdd;
	private RadioButtonAdapter rbaszhdd;
	private EditText et_szhdd;
	/** 颈部包块 */
	private MyGridView mgv_jbbk;
	private RadioButtonAdapter rbajbbk;
	private EditText et_jbbk;
	/** 肛门 */
	private MyGridView mgv_gm;
	private RadioButtonAdapter rbagm;
	private EditText et_gm;
	/** 外生殖器 */
	private MyGridView mgv_wszq;
	private RadioButtonAdapter rbawszq;
	private EditText et_wszq;
	/** 脊柱 */
	private MyGridView mgv_jz;
	private RadioButtonAdapter rbajz;
	private EditText et_jz;
	/** 皮肤 */
	private NiceSpinner ns_pifu;
	/** 脐带 */
	private NiceSpinner ns_qidai;
	/** 出生身长 */
	private EditText et_cssc;
	/** 出生体重 */
	private EditText et_xsrcstz;
	/** 出生日期 */
	private EditText et_csrq;
	/** 转诊建议mgv_zhuanzhenjianyi */
	private RadioGroup rd_zz;// 是否转诊
	private RadioButton rb_w;
	private RadioButton rb_y;
	private String str_zzId = "";
	/** 转诊原因 */
	private EditText ed_zzyy;
	/** 机构及科室 */
	private EditText ed_jg_ys;

	/** 指导mgv_zhidao */
	private MyGridView mgv_zhidao;
	/** 呼吸频率 */
	private EditText et_hxpl;
	/** 前囟 */
	private NiceSpinner ns_qx;
	private EditText et_qx1;
	private EditText et_qx2;
	private EditText et_qxqt;
	/** 新生儿疾病筛查 */
//	private EditText et_xsrjbsc;
	/** 出生孕周 */
	private EditText et_csyz;
	/** 父亲 */
	private static EditText et_fqxm;
	private EditText et_fqzy;
	private static EditText et_fqlxdh;
	private EditTextWithDate etw_fqcsrq;

	/** 母亲 */
	private static EditText et_mqxm;
	private EditText et_mqzy;
	private static EditText et_mqlxdh;
	private EditTextWithDate etw_mqcsrq;

	/** 家庭住址 */
	private EditText et_jtzz;
	/** 吃奶次数 */
	private EditText et_cncs;
	/** 本次随访日期 */
	private EditText etw_bcsfrq;
	/** 下次随访日期 */
	private EditTextWithDate etw_xcsfrq;
	private EditText et_xcsfdd;
	/** 随访医生签名 */
	private NiceSpinner et_sfysqm;
	/** 助产机构名称 */
	private EditText et_zcjgmc;

	/** 目前体重 */
	private EditText et_mqtz;
	/** 脉率 */
	private EditText et_ml;

	/** 性别 */
	private EditText et_xb;
	/** 皮肤 */
	private EditText et_pf;
	/** 大便次数 */
	private EditText et_dbcs;
	/** 体温 */
	private EditText et_tw;
	/** 脐带 */
	private EditText et_qd;
	/** 是否有畸形 */
	private EditText et_sfyjx;
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 小写的mm表示的是分钟

	@Override
	public View findViews(LayoutInflater inflater) {
		try {
			baseView = inflater.inflate(R.layout.ertong_xsrfs_fragment, null);
			fdbmanger = NovaApplication.fdbmanger;
			userInfo = NovaApplication.getUserInfo();
			IDCARD = NovaApplication.getUserInfo().getIDCARD();
			initViews();
			NovaApplication.dbManger.addColumnByBySQL("CHILD_NEWBORN_FOLLOWUP", "GUIDANCE_OTHER");
			/** */
			GlobalConts.setMaxLength(50, et_mqrsqhbqk// 母亲妊娠期患病情况
					, et_ywg, et_rwg);
			// 0-99
			GlobalConts.setMaxLength(2, et_mqrsqhbqk// 母亲妊娠期患病情况
			);
			// 0-999
			GlobalConts.setMaxLength(3, et_dbcs, et_cncs, et_mqrsqhbqk// 母亲妊娠期患病情况mononoki
																		// hack
																		// source
																		// code pro
					, et_ml, et_hxpl);
			GlobalConts.setMaxLength(50, et_qd, et_pf, et_sfyjx, et_qxqt, et_bi, et_kq, et_xftz, et_fbcz,
					et_szhdd, et_jbbk, et_gm, et_wszq, et_jz, ed_zzyy, ed_jg_ys);
			GlobalConts.setMaxLength(35, et_zcjgmc, et_jtzz);

			GlobalConts.setMaxLength(5, et_tw, et_mqtz, et_cssc, et_xsrcstz, et_qx1, et_qx2);
			GlobalConts.keep2decimal(et_cssc, et_xsrcstz, et_qx1, et_qx2, et_mqtz, et_tw);
			GlobalConts.setMaxLength(25, et_fqxm, et_mqxm, et_fqzy, et_mqzy);
			GlobalConts.setMaxLength(20, et_fqlxdh, et_mqlxdh);

			// 转诊建议50

			addListener();
			bind();
			initData();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return baseView;
	}

	private void saveData() {
		String strCy = et_csyz.getText().toString();
		if(!TextUtils.isEmpty(strCy)){
			if(Integer.parseInt(strCy)>42){
				((ChildActivity)getActivity()).showTextDialog("出生孕周最大值为42");
				return;
			}
		}
		CHILD_NEWBORN_FOLLOWUP cnf = new CHILD_NEWBORN_FOLLOWUP();



		if (!TextUtils.isEmpty(et_fqlxdh.getText().toString())) {
			if (GlobalConts.isPhoneNumberValid(et_fqlxdh.getText().toString())) {
				cnf.setFATHER_TEL(et_fqlxdh.getText().toString());
			} else {
				((ChildActivity)getActivity()).showTextDialog("父亲联系电话不正确");
				return;
			}
		} else {
			cnf.setFATHER_TEL(et_fqlxdh.getText().toString());
		}

		if (!TextUtils.isEmpty(et_mqlxdh.getText().toString())) {
			if (GlobalConts.isPhoneNumberValid(et_mqlxdh.getText().toString())) {
				cnf.setMOTHER_TEL(et_mqlxdh.getText().toString());
			} else {
				((ChildActivity)getActivity()).showTextDialog("母亲联系电话不正确");
				return;
			}
		} else {
			cnf.setMOTHER_TEL(et_mqlxdh.getText().toString());
		}
		String strXsrcstz = et_xsrcstz.getText().toString();
		if (!TextUtils.isEmpty(strXsrcstz) && Double.parseDouble(strXsrcstz) > 10) {
			((ChildActivity)getActivity()).showTextDialog("新生儿出生体重最大为10kg");
			et_xsrcstz.setBackgroundColor(getActivity().getResources().getColor(R.color.orange));
			return;
		} else {
			cnf.setBIRTH_WEIGHT(strXsrcstz);
		}
		String strMqtz = et_mqtz.getText().toString();
		if (!TextUtils.isEmpty(strMqtz) && Double.parseDouble(strMqtz) > 50) {
			((ChildActivity)getActivity()).showTextDialog("目前体重最大为50kg");
			et_mqtz.setBackgroundColor(getActivity().getResources().getColor(R.color.orange));
			return;
		} else {
			cnf.setPRESENT_WEIGHT(strMqtz);
		}
		String strcssc = et_cssc.getText().toString();
		if (!TextUtils.isEmpty(strcssc) && Double.parseDouble(strcssc) > 100) {
			((ChildActivity)getActivity()).showTextDialog("出生身长最大值为100cm");
			et_cssc.setBackgroundColor(getActivity().getResources().getColor(R.color.orange));
			return;
		} else {
			cnf.setBIRTH_STATURE(strcssc);
		}

		cnf.setABDOMINAL_TOUCH(rbaABDOMINAL_TOUCH.getChecked());
		cnf.setABDOMINAL_TOUCH_EX(et_fbcz.getText().toString());
		cnf.setAEDEA(rbawszq.getChecked());
		cnf.setAEDEA_EX(et_wszq.getText().toString());
		// cnf.setAGENCIES_DEPARTMENTS(et_bi);//机构及科室
		cnf.setANUS(rbagm.getChecked());
		cnf.setANUS_EX(et_gm.getText().toString());
		cnf.setAPGAR(rba_Apgar.getChecked());
		cnf.setARCHIVEID(userInfo.getARCHIVEID());// 档案编号
		cnf.setASPHYXIA(rba_xsrzx.getChecked());
		cnf.setBIRTH_INFORMA(cba_csqk.getChecked());
		System.out.println("存入" + cba_csqk.getCheckedOther());
		cnf.setBIRTH_INFORMA_OTHER(cba_csqk.getCheckedOther());
		cnf.setNOSE(rbabi.getChecked());
		cnf.setNOSE_EX(et_bi.getText().toString());
		cnf.setIS_UPDATE("Y");

		try {
			cnf.setBIRTHDAY(sdf.parse(et_csrq.getText().toString()));
			// TODO
		} catch (Exception e) {
			e.printStackTrace();
		}
		String strHxpl = et_hxpl.getText().toString();
		cnf.setBREATHING_RATE(strHxpl);
		cnf.setBREGMA(lstqx.get(ns_qianxin.getSelectedIndex()).getID());
		String strQx1 = et_qx1.getText().toString();
		cnf.setBREGMA_LEFT(strQx1);
		cnf.setBREGMA_OTHER(et_qxqt.getText().toString());
		String strQx2 = et_qx2.getText().toString();
		cnf.setBREGMA_RIGHT(strQx2);
		cnf.setCOLOUR_FACE(cbams.getChecked());
		cnf.setCOLOUR_FACE_OTHER(cbams.getCheckedOther());
		// cnf.setCREATED_BY(cREATED_BY);//创建人
		cnf.setCREATED_DATE(new Date());// 创建时间
		// cnf.setCUSTOMERID(cUSTOMERID);//客户编号
		cnf.setDISEASE_SCREEN(rbajbsc.getChecked());
		cnf.setDISEASE_SCREEN_OTHER(rbajbsc.getCheckedOther());
		cnf.setEAR_APPEARANCE(rbarwg.getChecked());
		// cnf.setEAR_APPEARANCE_EX(rbarwg.getCheckedOther());
		cnf.setEAR_APPEARANCE_EX(et_rwg.getText().toString());
		cnf.setEYE_APPEARANCE(rbaywg.getChecked());
		cnf.setEYE_APPEARANCE_EX(et_ywg.getText().toString());
		try {
			cnf.setFATHER_BIRTHDAY(sdf.parse(etw_fqcsrq.getText().toString()));
		} catch (Exception e) {
			e.printStackTrace();
		}
		cnf.setFATHER_JOB(et_fqzy.getText().toString());
		cnf.setFATHER_NAME(et_fqxm.getText().toString());

		cnf.setFEEDING_PATTERN(rba_xsrwyfs.getChecked());
		cnf.setFOLLOWUP_DOCTOR_SIGN(NovaApplication.getDoctorList().get(et_sfysqm.getSelectedIndex()).getUSER_ID());
		String strCsyz = et_csyz.getText().toString();
		cnf.setGESTATIONAL_WEEK(strCsyz);
		cnf.setGUIDANCE(cbazhidao.getCheckedIdsStr());
		cnf.setGUIDANCE_OTHER(cbazhidao.getOther());

		cnf.setHEARING_SCREEN(cbatlsc.getChecked());
		cnf.setHEART_LUNG_AUSCUL(rbaxftz.getChecked());
		cnf.setHEART_LUNG_AUSCUL_EX(et_xftz.getText().toString());
		cnf.setHOME_ADDR(et_jtzz.getText().toString());
		// cnf.setID(iD);
		cnf.setIDCARD(userInfo.getIDCARD());
		String strCncs = et_cncs.getText().toString();
		cnf.setINFANT_FREQUEN(strCncs);
		String strXnl = et_cnl.getText().toString();
		cnf.setNURSING_QUANTITY(strXnl);
		try {
			cnf.setINTERVIEW_DATE(sdf.parse(etw_bcsfrq.getText().toString()));
		} catch (Exception e) {
			e.printStackTrace();
		}

		// cnf.setIS_DEL(iS_DEL);//是否删除

		cnf.setJAUNDICE(rba_huangdan.getChecked());
		// cnf.setLAST_UPDATE_BY(lAST_UPDate_BY);//修改人
		cnf.setLAST_UPDATE_DATE(new Date());
		cnf.setLIMBS_ACTIVITY(rbaszhdd.getChecked());
		cnf.setLIMBS_ACTIVITY_EX(et_szhdd.getText().toString());
		cnf.setMIDWIF_ORGANIZA_NAME(et_zcjgmc.getText().toString());
		if (rb_w.isChecked()) {
			str_zzId = "DM01-11_1";
		} else if (rb_y.isChecked()) {
			str_zzId = "DM01-11_2";
		} else {
			str_zzId = "";
		}
		cnf.setREFERRAL_ADVICE(str_zzId);
		cnf.setREFERRAL_REASON(ed_zzyy.getText().toString());
		cnf.setAGENCIES_DEPARTMENTS(ed_jg_ys.getText().toString());

		try {
			cnf.setMOTHER_BIRTHDAY(sdf.parse(etw_mqcsrq.getText().toString()));
		} catch (Exception e) {
			e.printStackTrace();
		}
		cnf.setMOTHER_JOB(et_mqzy.getText().toString());
		cnf.setMOTHER_NAME(et_mqxm.getText().toString());


		cnf.setMOUTH_CAVITY(rbakq.getChecked());
		cnf.setMOUTH_CAVITY_EX(et_kq.getText().toString());
		cnf.setNECK_MASS(rbajbbk.getChecked());
		cnf.setNECK_MASS_HAVE(et_jbbk.getText().toString());
		if(TextUtils.isEmpty(etw_xcsfrq.getText())){
			((ChildActivity)getActivity()).showTextDialog("下次随访日期不能为空");
			etw_xcsfrq.setBackgroundColor(getActivity().getResources().getColor(R.color.orange));
			return;
		}else{
			try {
				cnf.setNEXT_FOLLOWUP_DATE(sdf.parse(etw_xcsfrq.getText().toString()));
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}

		if(TextUtils.isEmpty(et_xcsfdd.getText())){
			((ChildActivity)getActivity()).showTextDialog("下次随访地点不能为空");
			et_xcsfdd.setBackgroundColor(getActivity().getResources().getColor(R.color.orange));
			return;
		}else{
			cnf.setNEXT_FOLLOWUP_PLACE(et_xcsfdd.getText().toString());
		}

		cnf.setPREGNANC_PREVA(lstrsqk.get(ns_mqrsqhbqk.getSelectedIndex()).getID());
		cnf.setPREGNANC_PREVA_OTHER(et_mqrsqhbqk.getText().toString());



		String strml = et_ml.getText().toString();
		cnf.setPULSE_RATE(strml);
		cnf.setSEX(et_xb.getText().toString());
		cnf.setSKIN(lstpf.get(ns_pifu.getSelectedIndex()).getID());
		cnf.setSKIN_OTHER(et_pf.getText().toString());
		cnf.setSPINE(rbajz.getChecked());
		cnf.setSPINE_EX(et_jz.getText().toString());
		cnf.setSTOOL(dabianrba.getChecked());
		String strDbcs = et_dbcs.getText().toString();
		cnf.setSTOOL_FREQUEN(strDbcs);
		String strTw = et_tw.getText().toString();
		cnf.setTEMPERATURE(strTw);
		cnf.setUMBILICAL_CORD(lstqd.get(ns_qidai.getSelectedIndex()).getID());
		cnf.setUMBILICAL_CORD_OTHER(et_qd.getText().toString());
		cnf.setVOMIT(oturba.getChecked());
		cnf.setWHETHER_ABNORMA(rbasfyjx.getChecked());
		cnf.setWHETHER_ABNORMA_HAVE(rbasfyjx.getCheckedOther());
		cnf.setLAST_UPDATE_BY(NovaApplication.getDoctorList().get(et_sfysqm.getSelectedIndex()).getUSER_ID());
		cnf.setLAST_UPDATE_DATE(new Date());
		if (from == 0) {
			cnf.setCREATED_BY(userInfo.getCREATED_BY());
			cnf.setCREATED_DATE(new Date());
			cnf.setCREATEORG(userInfo.getCREATEORG());
			cnf.setCREATER(userInfo.getCREATER());
			FDbManager.getInstance(getActivity()).save(cnf);
			from = 1;
		} else {

			cnf.setUPDATEORG(userInfo.getCREATEORG());
			cnf.setMODIFIED(NovaApplication.getDoctorList().get(et_sfysqm.getSelectedIndex()).getUSER_ID());
			FDbManager.getInstance(getActivity()).updata(cnf, "IDCARD='" + userInfo.getIDCARD() + "'");
		}
//		((ChildActivity) getActivity()).showTextDialog("保存成功");
		if (GlobalConts.TYPE_JTYS.equals(NovaApplication.getType())) {
			new AlertDialog.Builder(getActivity()).setTitle("保存成功").setMessage("进行满意度评价")
					.setPositiveButton("确定", new DialogInterface.OnClickListener() {

						@Override
						public void onClick(DialogInterface dialog, int which) {
							Intent intent = new Intent(getContext(), FWMYDPJActivity.class);
							intent.putExtra("type", "02");
							intent.putExtra("szfs","");
							startActivity(intent);
						}
					}).show();
		} else if (GlobalConts.TYPE_GJJBGGWS.equals(NovaApplication.getType())) {
			((ChildActivity) getActivity()).showTextDialog("保存成功");
		}
	}

	private int from;
	private List<BD_DD_INFO> bdxingbie;

	private void initData() {

		try {
			GlobalConts.keep2decimal(et_xsrcstz);
			GlobalConts.keep2decimal(et_mqtz);
			GlobalConts.keep2decimal(et_tw);
			GlobalConts.checkNumOrange(getActivity(), et_tw, 43, 30);
			GlobalConts.checkXSEFS(getActivity(), et_xsrcstz, 10.0, "新生儿出生体重最大为10kg");
			GlobalConts.checkXSEFS(getActivity(), et_mqtz, 50.0, "目前体重最大为50kg");
			GlobalConts.checkNumOrange(getActivity(), et_cncs, 100, 0);
			GlobalConts.checkNumOrange(getActivity(), et_dbcs, 100, 0);
			GlobalConts.checkNumOrange(getActivity(), et_hxpl, 100, 0);
			GlobalConts.checkXSEFS(getActivity(), et_cssc, 100.0, "出生身长最大值为100cm");
			GlobalConts.checkNumOrange(getActivity(), et_ml, 200, 0);
			try {
				String sex = "";
				bdxingbie = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
						"PARENTID = 'DM01-08'");
				for (BD_DD_INFO bdi : bdxingbie) {
					if (userInfo.getSEX().equals(bdi.getID())) {
						sex = bdi.getDATAINFO();
					}
				}
				et_xb.setText(sex);

				et_csrq.setText(sdf.format(userInfo.getBIRTHDAY()));
			} catch (Exception e) {
				e.printStackTrace();
			}

			et_xingming.setText(userInfo.getCUSTOMERNAME());
			et_shenfenzhenghao.setText(userInfo.getIDCARD());
			et_jtzz.setText(userInfo.getADDR());
			// CHILD_NEWBORN_FOLLOWUP cnf = new CHILD_NEWBORN_FOLLOWUP();
			etw_bcsfrq.setText(sdf.format(new Date()));

			List<CHILD_NEWBORN_FOLLOWUP> cnfs = fdbmanger.findAllByWhere(CHILD_NEWBORN_FOLLOWUP.class,
					"IDCARD = '" + userInfo.getIDCARD() + "'");

			if (cnfs.size() > 0) {

				from = 1;
				CHILD_NEWBORN_FOLLOWUP cnf = cnfs.get(cnfs.size() - 1);

				rbaABDOMINAL_TOUCH.setChecked(cnf.getABDOMINAL_TOUCH());
				et_fbcz.setText(cnf.getABDOMINAL_TOUCH_EX());
				rbawszq.setChecked(cnf.getAEDEA());
				et_wszq.setText(cnf.getAEDEA_EX());
				// cnf.getAGENCIES_DEPARTMENTS(et_bi);//机构及科室
				rbagm.setChecked(cnf.getANUS());
				et_gm.setText(cnf.getANUS_EX());
				rba_Apgar.setChecked(cnf.getAPGAR());

				str_zzId = cnf.getREFERRAL_ADVICE();

				if (!TextUtils.isEmpty(str_zzId)) {
					if (str_zzId.equals("DM01-11_1")) {
						rb_w.setChecked(true);
					} else if (str_zzId.equals("DM01-11_2")) {
						rb_y.setChecked(true);
					}
				}

				// adapter_zz.setChecked(str_zzId);

				ed_zzyy.setText(cnf.getREFERRAL_REASON());
				ed_jg_ys.setText(cnf.getAGENCIES_DEPARTMENTS());

				// cnf.getARCHIVEID(aRCHIVEID);//档案编号
				rba_xsrzx.setChecked(cnf.getASPHYXIA());
				System.out.println(cnf.getASPHYXIA() + "新生儿窒息");
				if ("DM01-11_2".equals(cnf.getASPHYXIA())) {
					mgv_Apgar.setDisable(true);
				} else {
					mgv_Apgar.setDisable(false);
				}
				cba_csqk.setChecked(cnf.getBIRTH_INFORMA(), cnf.getBIRTH_INFORMA_OTHER());
				System.out.println("取出：" + cnf.getBIRTH_INFORMA_OTHER());
				// et_csqk.setText();
				et_cssc.setText(cnf.getBIRTH_STATURE() + "");
				// String strXsrcstz = .getText().toString();
				et_xsrcstz.setText(cnf.getBIRTH_WEIGHT() + "");
				try {
					et_csrq.setText(sdf.format(cnf.getBIRTHDAY()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				// String strHxpl = .getText().toString();
				et_hxpl.setText(cnf.getBREATHING_RATE() + "");
				ns_qianxin.setSelectedIndex(getListIndex(cnf.getBREGMA(), lstqx));
				// String strQx1 = et_qx1.getText().toString();
				et_qx1.setText(cnf.getBREGMA_LEFT() + "");
				et_qxqt.setText(cnf.getBREGMA_OTHER());
				// String strQx2 = et_qx2.getText().toString();
				et_qx2.setText(cnf.getBREGMA_RIGHT() + "");
				cbams.setChecked(cnf.getCOLOUR_FACE(), cnf.getCOLOUR_FACE_OTHER());
				// cnf.getCREATED_BY(cREATED_BY);//创建人
				// cnf.getCREATED_DATE(new Date());// 创建时间
				// cnf.getCUSTOMERID(cUSTOMERID);//客户编号
				rbajbsc.setChecked(cnf.getDISEASE_SCREEN(),cnf.getDISEASE_SCREEN_OTHER());

				rbarwg.setChecked(cnf.getEAR_APPEARANCE());
				et_rwg.setText(cnf.getEAR_APPEARANCE_EX());
				// rbarwg.setChecked(cnf.getEAR_APPEARANCE(),
				// cnf.getEAR_APPEARANCE_EX());
				rbaywg.setChecked(cnf.getEYE_APPEARANCE());// ,
				et_ywg.setText(cnf.getEYE_APPEARANCE_EX());//
				rbabi.setChecked(cnf.getNOSE());
				et_bi.setText(cnf.getNOSE_EX());
				// cnf.getEYE_APPEARANCE(rbaywg.getChecked());
				// cnf.getEYE_APPEARANCE_EX(rbaywg.getCheckedOther());
				try {
					etw_fqcsrq.setText(sdf.format(cnf.getFATHER_BIRTHDAY()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				et_fqzy.setText(cnf.getFATHER_JOB());
				et_fqxm.setText(cnf.getFATHER_NAME());
				et_fqlxdh.setText(cnf.getFATHER_TEL());
				rba_xsrwyfs.setChecked(cnf.getFEEDING_PATTERN());
				for (int i = 0; i < NovaApplication.getDoctorList().size(); i++) {
					if (cnf.getFOLLOWUP_DOCTOR_SIGN().equals(NovaApplication.getDoctorList().get(i).getUSER_ID())) {
						et_sfysqm.setSelectedIndex(i);
					}

				}
				// String strCsyz = et_csyz.getText().toString();
				et_csyz.setText(cnf.getGESTATIONAL_WEEK() + "");
				cbazhidao.setChecked(cnf.getGUIDANCE());
				cbazhidao.setOther(cnf.getGUIDANCE_OTHER());

				cbatlsc.setChecked(cnf.getHEARING_SCREEN());
				rbaxftz.setChecked(cnf.getHEART_LUNG_AUSCUL());
				et_xftz.setText(cnf.getHEART_LUNG_AUSCUL_EX());
				et_jtzz.setText(cnf.getHOME_ADDR());
				// cnf.getID(iD);
				// cnf.getIDCARD(userInfo.getIDCARD());
				// String strCncs = et_cncs.getText().toString();
				et_cncs.setText(cnf.getINFANT_FREQUEN() + "");
				et_cnl.setText(cnf.getNURSING_QUANTITY() + "");
				try {
					etw_bcsfrq.setText(sdf.format(cnf.getINTERVIEW_DATE()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				rba_huangdan.setChecked(cnf.getJAUNDICE());
				// cnf.getIS_DEL(iS_DEL);//是否删除
				// cnf.getLAST_UPDATE_BY(lAST_UPDate_BY);//修改人
				// cnf.getLAST_UPDATE_DATE(new Date());
				rbaszhdd.setChecked(cnf.getLIMBS_ACTIVITY());
				et_szhdd.setText(cnf.getLIMBS_ACTIVITY_EX());
				et_zcjgmc.setText(cnf.getMIDWIF_ORGANIZA_NAME());
				try {
					etw_mqcsrq.setText(sdf.format(cnf.getMOTHER_BIRTHDAY()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				et_mqzy.setText(cnf.getMOTHER_JOB());
				et_mqxm.setText(cnf.getMOTHER_NAME());
				et_mqlxdh.setText(cnf.getMOTHER_TEL());
				rbakq.setChecked(cnf.getMOUTH_CAVITY());
				et_kq.setText(cnf.getMOUTH_CAVITY_EX());
				// cnf.getMOUTH_CAVITY_EX(rbakq.getCheckedOther());
				rbajbbk.setChecked(cnf.getNECK_MASS());
				et_jbbk.setText(cnf.getNECK_MASS_HAVE());
				// rbajbbk.setChecked(cnf.getNECK_MASS_HAVE(rbajbbk.getCheckedOther());
				try {
					etw_xcsfrq.setText(sdf.format(cnf.getNEXT_FOLLOWUP_DATE()));
				} catch (Exception e) {
					e.printStackTrace();
				}
				et_xcsfdd.setText(cnf.getNEXT_FOLLOWUP_PLACE());
				ns_mqrsqhbqk.setSelectedIndex(getListIndex(cnf.getPREGNANC_PREVA(), lstrsqk));
				et_mqrsqhbqk.setText(cnf.getPREGNANC_PREVA_OTHER());// et_mqrsqhbqk.getText().toString());
				// String strMqtz = et_mqtz.getText().toString();
				et_mqtz.setText(cnf.getPRESENT_WEIGHT() + "");// strMqtz.isEmpty()
																// ?
				// I_NULL :
				// Integer.parseInt(strMqtz));
				// String strml = et_ml.getText().toString();
				et_ml.setText(cnf.getPULSE_RATE() + "");// strml.isEmpty()
														// ?
														// I_NULL
														// :
				// et_xb.setText(cnf.getSEX());
				ns_pifu.setSelectedIndex(getListIndex(cnf.getSKIN(), lstpf));
				et_pf.setText(cnf.getSKIN_OTHER());
				rbajz.setChecked(cnf.getSPINE());
				et_jz.setText(cnf.getSPINE_EX());
				dabianrba.setChecked(cnf.getSTOOL());
				et_dbcs.setText(cnf.getSTOOL_FREQUEN() + "");
				// String strTw = et_tw.getText().toString();
				et_tw.setText(cnf.getTEMPERATURE() + "");
				ns_qidai.setSelectedIndex(getListIndex(cnf.getUMBILICAL_CORD(), lstqd));
				et_qd.setText(cnf.getUMBILICAL_CORD_OTHER());
				oturba.setChecked(cnf.getVOMIT());
				rbasfyjx.setChecked(cnf.getWHETHER_ABNORMA(), cnf.getWHETHER_ABNORMA_HAVE());
				// et_sfy
				// cnf.getWHETHER_ABNORMA_HAVE(rbasfyjx.getCheckedOther());
			} else {
				from = 0;
				etw_bcsfrq.setText(sdf.format(new Date()));
				for (int i = 0; i < NovaApplication.getDoctorList().size(); i++) {
					if (userInfo.getCREATED_BY().equals(NovaApplication.getDoctorList().get(i).getUSER_ID())) {
						et_sfysqm.setSelectedIndex(i);
					}

				}

				setFatherMatherData();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	List<BD_DD_INFO> lstqx;
	RadioButtonAdapter cbams;
	RadioButtonAdapter rbajbsc;

	List<BD_DD_INFO> lstwyfs;
	RadioButtonAdapter cbatlsc;
	List<BD_DD_INFO> lsthd;
	List<BD_DD_INFO> lstrsqk;
	List<BD_DD_INFO> lstpf;
	RadioButtonAdapter dabianrba;
	List<BD_DD_INFO> lstqd;
	RadioButtonAdapter oturba;
	RadioButtonAdapter rbasfyjx;

	// mgv_xsrjbsc
	public void bind() {
		GlobalConts.checkNumOrange(getActivity(), et_csyz, 42, 0);

		lstWY = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-11' order by cast(SORT as int) asc");
		lstyc = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM01-40' order by cast(SORT as int) asc");
		// 母亲身份证号位数
		// List<BD_DD_INFO> lst =
		// FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
		// "PARENTID = 'DM100-02' order by cast(SORT as int) asc");
		// mgv_mqrsqhbqk.attachDataSource(getDataInfo(lst));
		// 母亲妊娠期患病情况DM05-05
		lstrsqk = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM05-05' order by cast(SORT as int) asc");
		Collections.reverse(lstrsqk);

		ns_mqrsqhbqk.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if ("其他".equals(s.toString())) {
					et_mqrsqhbqk.setEnabled(true);
				} else {
					et_mqrsqhbqk.setText("");
					et_mqrsqhbqk.setEnabled(false);
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});
		ns_qidai.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if ("其他".equals(s.toString())) {
					et_qd.setEnabled(true);
				} else {
					et_qd.setText("");
					et_qd.setEnabled(false);
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});
		ns_mqrsqhbqk.attachDataSource(getDataInfo(lstrsqk));
		// 新生儿窒息DM01-11_1
		// lstXsrzx
		rba_xsrzx = new RadioButtonAdapter(lstWY, getActivity());
		rba_xsrzx.setOtherTextVisible(false);
		mgv_xsrzx.setAdapter(rba_xsrzx);
		// 出生情况DM05-30_7

		bindDdata("出生情况", "PARENTID = 'DM05-30'");

		bindDdata("Apgar评分", "PARENTID = 'DM05-7'");

		bindDdata("新生儿听力筛查", "PARENTID = 'DM05-9'");

		bindDdata("新生儿疾病筛查", "PARENTID = 'DM05-02'");

		bindDdata("新生儿喂养方式", "PARENTID = 'DM05-11'");
		bindDdata("大便", "PARENTID = 'DM05-13'");
		bindDdata("面色", "PARENTID = 'DM05-14_1'");

		bindDdata("黄疸", "PARENTID = 'DM05-15'");
		bindDdata("前囟", "PARENTID = 'DM05-16_2'");

		// 是否有畸形
		rbasfyjx = new RadioButtonAdapter(lstWY, getActivity(), et_sfyjx);
		rbasfyjx.setOtherMaxLength(50);
		rbasfyjx.setOtherTextVisible(false);
		mgv_sfyjx.setAdapter(rbasfyjx);

		// 呕吐
		oturba = new RadioButtonAdapter(lstWY, getActivity());
		otu.setAdapter(oturba);
		oturba.setOtherTextVisible(false);

		/** 眼外观------腹部触诊 */
		// lstyc
		rbaywg = new RadioButtonAdapter(lstyc, getActivity(), et_ywg);
		rbarwg = new RadioButtonAdapter(lstyc, getActivity(), et_rwg);
		rbabi = new RadioButtonAdapter(lstyc, getActivity(), et_bi);
		rbakq = new RadioButtonAdapter(lstyc, getActivity(), et_kq);
		rbaxftz = new RadioButtonAdapter(lstyc, getActivity(), et_xftz);
		rbaABDOMINAL_TOUCH = new RadioButtonAdapter(lstyc, getActivity(), et_fbcz);
		rbaywg.setOtherMaxLength(50);
		rbarwg.setOtherMaxLength(50);
		rbabi.setOtherMaxLength(50);
		rbakq.setOtherMaxLength(50);
		rbaxftz.setOtherMaxLength(50);
		rbaABDOMINAL_TOUCH.setOtherMaxLength(50);

		rbaywg.setOtherTextVisible(false);
		rbarwg.setOtherTextVisible(false);
		rbabi.setOtherTextVisible(false);
		rbakq.setOtherTextVisible(false);
		rbaxftz.setOtherTextVisible(false);
		rbaABDOMINAL_TOUCH.setOtherTextVisible(false);

		mgv_ywg.setAdapter(rbaywg);
		mgv_rwg.setAdapter(rbarwg);
		mgv_bi.setAdapter(rbabi);
		mgv_kq.setAdapter(rbakq);
		mgv_xftz.setAdapter(rbaxftz);
		mgv_fbcz.setAdapter(rbaABDOMINAL_TOUCH);
		/** 四肢活动度---脊柱 */
		rbaszhdd = new RadioButtonAdapter(lstyc, getActivity(), et_szhdd);
		rbajbbk = new RadioButtonAdapter(lstWY, getActivity(), et_jbbk);
		rbagm = new RadioButtonAdapter(lstyc, getActivity(), et_gm);
		rbawszq = new RadioButtonAdapter(lstyc, getActivity(), et_wszq);
		rbajz = new RadioButtonAdapter(lstyc, getActivity(), et_jz);
		rbaszhdd.setOtherMaxLength(50);
		rbajbbk.setOtherMaxLength(50);
		rbagm.setOtherMaxLength(50);
		rbawszq.setOtherMaxLength(50);
		rbajz.setOtherMaxLength(50);
		rbaszhdd.setOtherTextVisible(false);
		rbajbbk.setOtherTextVisible(false);
		rbagm.setOtherTextVisible(false);
		rbawszq.setOtherTextVisible(false);
		rbajz.setOtherTextVisible(false);

		mgv_szhdd.setAdapter(rbaszhdd);
		mgv_jbbk.setAdapter(rbajbbk);
		mgv_gm.setAdapter(rbagm);
		mgv_wszq.setAdapter(rbawszq);
		mgv_jz.setAdapter(rbajz);

		/** 皮肤DM05-17 */
		lstpf = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM05-17' order by cast(SORT as int) asc");
		ns_pifu.attachDataSource(getDataInfo(lstpf));
		/** 脐带DM05-18 */
		lstqd = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM05-18' order by cast(SORT as int) asc");
		ns_qidai.attachDataSource(getDataInfo(lstqd));
		/** 指导mgv_zhidaoDM05-04DM05-25 */
		List<BD_DD_INFO> lstzd = FDbManager.getInstance(getActivity()).findAllByWhereInInfoDB(BD_DD_INFO.class,
				"PARENTID = 'DM05-25' order by cast(SORT as int) asc");
		cbazhidao = new CheckBoxAdapter(getActivity(), lstzd);
		mgv_zhidao.setAdapter(cbazhidao);
		// 随访医生
		GlobalConts.doctorList( et_sfysqm);
	}

	CheckBoxAdapter cbazhidao;

	/**
	 * 获取下拉框中需要的数据的信息
	 *
	 * @param datas
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月16日 下午3:47:00
	 */
	private ArrayList<String> getDataInfo(List<BD_DD_INFO> datas) {
		ArrayList<String> infos = new ArrayList<String>();
		for (BD_DD_INFO bd : datas) {
			infos.add(bd.getDATAINFO());
		}
		return infos;
	}

	@Override
	public void setupView(View view) {
	}

	@Override
	public void addListener() {
		etw_fqcsrq.setBefore(new Date());
		etw_mqcsrq.setBefore(new Date());
		rd_zz.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if (checkedId == R.id.rb_w) {
					str_zzId = "DM01-11_1";
					ed_zzyy.setText("");
					ed_jg_ys.setText("");
					ed_zzyy.setEnabled(false);
					ed_jg_ys.setEnabled(false);

				} else if (checkedId == R.id.rb_y) {
					str_zzId = "DM01-11_2";
					ed_zzyy.setEnabled(true);
					ed_jg_ys.setEnabled(true);
				} else {
					str_zzId = "";
				}

			}
		});
		ns_pifu.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if (s != null && "其他".equals(s.toString())) {
					et_pf.setEnabled(true);
				} else {
					et_pf.setText("");
					et_pf.setEnabled(false);
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});
		ns_qianxin.addTextChangedListener(new TextWatcher() {

			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if (s != null && "其他".equals(s.toString())) {
					et_qxqt.setEnabled(true);
				} else {
					et_qxqt.setText("");
					et_qxqt.setEnabled(false);
				}
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
			}
		});
	}

	@Override
	public void setData() {

	}

	public int getListIndex(String id, List<BD_DD_INFO> bds) {
		int index = 0;
		try {
			for (int i = 0; i < bds.size(); i++) {
				if (id.equals(bds.get(i).getID())) {
					index = i;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return index;
	}

	/**
	 * 字符串转换"1,2,3,4,5" --> "'1','2','3','4','5'"
	 *
	 * @param symptom
	 * @return
	 * @author 鹿云龙
	 * @date 2015年12月19日 下午2:49:23
	 */
	public String checkedIdsSql(String symptom) {
		String[] idarr = symptom.split(",");
		String sql = "";
		for (String id : idarr) {
			sql += "'" + id + "',";
		}
		sql = sql.substring(0, sql.length() - 1);
		System.out.println(sql);
		return sql;
	}

	@Override
	public void save() {
		saveData();
	}

	@Override
	public void onStart() {
		super.onStart();
	}

	/**
	 * ·1 绑定数据值
	 *
	 * @param str_where
	 * @param flag
	 * @author 王婷婷
	 * @date 2015年12月17日 上午10:30:30
	 */
	private void bindDdata(String flag, String str_where) {
		List<BD_DD_INFO> listZZs = fdbmanger.findAllByWhereInInfoDB(BD_DD_INFO.class,
				str_where + " order by cast(SORT as int) asc");

		if (flag.equals("出生情况")) {
			cba_csqk = new RadioButtonAdapter(listZZs, getActivity());
			cba_csqk.setOtherMaxLength(50);
			mgv_csqk.setAdapter(cba_csqk);
		} else if (flag.equals("Apgar评分")) {
			rba_Apgar = new RadioButtonAdapter(listZZs, getActivity());
			mgv_Apgar.setAdapter(rba_Apgar);
		} else if (flag.equals("新生儿听力筛查")) {
			// 新生儿听力筛查DM05-9
			cbatlsc = new RadioButtonAdapter(listZZs, getActivity());
			mgv_xsrtlsc.setAdapter(cbatlsc);
		} else if (flag.equals("新生儿疾病筛查")) {
			List<BD_DD_INFO> listZZs_new = new ArrayList<BD_DD_INFO>();
			int size = listZZs.size();
			if (size > 0) {
				for (int i = 0; i < size; i++) {

					//DM05-02_1	1	甲低
//					DM05-02_2	2	苯丙酮尿症
//					DM05-02_3	3	6-磷酸葡萄糖脱氢酶缺乏症
//					DM05-02_4	4	先天性肾上腺皮质增生症
//					DM05-02_5	5	半乳檎血症
//					DM05-02_6	6	地中海贫血
//					DM05-02_7	9	其他遗传代谢病
//					if (listZZs.get(i).getID().equals("DM05-02_1") || listZZs.get(i).getID().equals("DM05-02_2")
//							|| listZZs.get(i).getID().equals("DM05-02_7")|| listZZs.get(i).getID().equals("DM05-02_7") ) {
						listZZs_new.add(listZZs.get(i));
//					}
				}
			}

			rbajbsc = new RadioButtonAdapter(listZZs_new,getActivity());
			mgv_xsrjbsc.setAdapter(rbajbsc);
		} else if (flag.equals("新生儿喂养方式")) {
			// 新生儿喂养方式
			rba_xsrwyfs = new RadioButtonAdapter(listZZs, getActivity());
			mgv_xsrwyfs.setAdapter(rba_xsrwyfs);
		} else if (flag.equals("大便")) {
			// 大便DM05-13
			dabianrba = new RadioButtonAdapter(listZZs, getActivity());
			dabian.setAdapter(dabianrba);
		} else if (flag.equals("面色")) {
			// 面色DM05-14_1
			cbams = new RadioButtonAdapter(listZZs, getActivity());
			mgv_mianse.setAdapter(cbams);
		} else if (flag.equals("黄疸")) {
			// 黄疸DM05-15
			rba_huangdan = new RadioButtonAdapter(listZZs, getActivity());
			mgv_huangdan.setAdapter(rba_huangdan);
		} else if (flag.equals("前囟")) {
			// 前囟DM05-16_2
			lstqx = listZZs;
			ns_qianxin.attachDataSource(getDataInfo(lstqx));
		}
	}

	/**
	 * 初始化布局
	 *
	 * @author 王婷婷
	 * @date 2017年3月22日 下午4:43:00
	 */
	private void initViews() {
		et_shenfenzhenghao = (EditText) baseView.findViewById(R.id.et_shenfenzhenghao);

		ns_mqrsqhbqk = (NiceSpinner) baseView.findViewById(R.id.mgv_mqrsqhbqk);

		mgv_xsrzx = (MyGridView) baseView.findViewById(R.id.mgv_xsrzx);

		mgv_Apgar = (MyGridView) baseView.findViewById(R.id.mgv_Apgar);

		mgv_sfyjx = (MyGridView) baseView.findViewById(R.id.mgv_sfyjx);

		mgv_xsrtlsc = (MyGridView) baseView.findViewById(R.id.mgv_xsrtlsc);

		mgv_xsrjbsc = (MyGridView) baseView.findViewById(R.id.mgv_xsrjbsc);

		mgv_xsrwyfs = (MyGridView) baseView.findViewById(R.id.mgv_xsrwyfs);

		ns_qianxin = (NiceSpinner) baseView.findViewById(R.id.ns_qx);

		dabian = (MyGridView) baseView.findViewById(R.id.mgv_dabian);

		otu = (MyGridView) baseView.findViewById(R.id.mgv_otu);

		mgv_mianse = (MyGridView) baseView.findViewById(R.id.mgv_mianse);

		mgv_huangdan = (MyGridView) baseView.findViewById(R.id.mgv_huangdan);

		mgv_ywg = (MyGridView) baseView.findViewById(R.id.mgv_ywg);
		et_ywg = (EditText) baseView.findViewById(R.id.et_ywg);
		mgv_rwg = (MyGridView) baseView.findViewById(R.id.mgv_rwg);
		mgv_bi = (MyGridView) baseView.findViewById(R.id.mgv_3);
		mgv_kq = (MyGridView) baseView.findViewById(R.id.mgv_4);
		mgv_xftz = (MyGridView) baseView.findViewById(R.id.mgv_5);
		mgv_fbcz = (MyGridView) baseView.findViewById(R.id.mgv_6);

		mgv_szhdd = (MyGridView) baseView.findViewById(R.id.mgv_7);
		mgv_jbbk = (MyGridView) baseView.findViewById(R.id.mgv_jbbk);
		// mgv_9 = (MyGridView) baseView.findViewById(R.id.mgv_9);
		mgv_gm = (MyGridView) baseView.findViewById(R.id.mgv_10);
		mgv_wszq = (MyGridView) baseView.findViewById(R.id.mgv_11);
		mgv_jz = (MyGridView) baseView.findViewById(R.id.mgv_12);

		ns_pifu = (NiceSpinner) baseView.findViewById(R.id.ns_pifu);
		ns_qidai = (NiceSpinner) baseView.findViewById(R.id.ns_qidai);

		ed_zzyy = (EditText) baseView.findViewById(R.id.ed_zzyy);
		ed_jg_ys = (EditText) baseView.findViewById(R.id.ed_jg_ys);
		rd_zz = (RadioGroup) baseView.findViewById(R.id.rd_zz);
		rb_w = (RadioButton) baseView.findViewById(R.id.rb_w);
		rb_y = (RadioButton) baseView.findViewById(R.id.rb_y);
		ed_zzyy.setEnabled(false);
		ed_jg_ys.setEnabled(false);

		mgv_zhidao = (MyGridView) baseView.findViewById(R.id.mgv_zhidao);

		mgv_csqk = (MyGridView) baseView.findViewById(R.id.mgv_xsrqk);

		et_cssc = (EditText) baseView.findViewById(R.id.et_cssc);
		et_qx1 = (EditText) baseView.findViewById(R.id.et_qx1);
		et_qx2 = (EditText) baseView.findViewById(R.id.et_qx2);
		et_qxqt = (EditText) baseView.findViewById(R.id.et_qxqt);

		et_fqxm = (EditText) baseView.findViewById(R.id.et_fqxm);
		et_fqzy = (EditText) baseView.findViewById(R.id.et_fqzy);
		et_fqlxdh = (EditText) baseView.findViewById(R.id.et_fqlxdh);
		etw_fqcsrq = (EditTextWithDate) baseView.findViewById(R.id.etw_fqcsrq);

		et_mqxm = (EditText) baseView.findViewById(R.id.et_mqxm);
		et_mqzy = (EditText) baseView.findViewById(R.id.et_mqzy);
		et_mqlxdh = (EditText) baseView.findViewById(R.id.et_mqlxdh);
		etw_mqcsrq = (EditTextWithDate) baseView.findViewById(R.id.etw_mqcsrq);
		et_jtzz = (EditText) baseView.findViewById(R.id.et_jtzz);

		et_cncs = (EditText) baseView.findViewById(R.id.et_cncs);
		et_cnl = (EditText) baseView.findViewById(R.id.et_cnl);

		etw_bcsfrq = (EditTextWithDate) baseView.findViewById(R.id.etw_bcsfrq);
		etw_xcsfrq = (EditTextWithDate) baseView.findViewById(R.id.etw_xcsfrq);
		et_zcjgmc = (EditText) baseView.findViewById(R.id.et_zcjgmc);
		et_xcsfdd = (EditText) baseView.findViewById(R.id.et_xcsfdd);
		et_mqrsqhbqk = (EditText) baseView.findViewById(R.id.et_mqrsqhbqk);
		et_ml = (EditText) baseView.findViewById(R.id.et_ml);
		et_xb = (EditText) baseView.findViewById(R.id.et_xb);
		et_pf = (EditText) baseView.findViewById(R.id.et_pf);
		et_dbcs = (EditText) baseView.findViewById(R.id.et_dbcs);
		et_tw = (EditText) baseView.findViewById(R.id.et_tw);
		et_fbcz = (EditText) baseView.findViewById(R.id.et_fbcz);
		et_wszq = (EditText) baseView.findViewById(R.id.et_wszq);
		et_gm = (EditText) baseView.findViewById(R.id.et_gm);
		et_xsrcstz = (EditText) baseView.findViewById(R.id.et_xsrcstz);
		et_hxpl = (EditText) baseView.findViewById(R.id.et_hxpl);
		et_sfysqm = (NiceSpinner) baseView.findViewById(R.id.et_sfysqm);
		et_csyz = (EditText) baseView.findViewById(R.id.et_csyz);
		et_mqtz = (EditText) baseView.findViewById(R.id.et_mqtz);
		et_ml = (EditText) baseView.findViewById(R.id.et_ml);
		et_qd = (EditText) baseView.findViewById(R.id.et_qd);
		et_csrq = (EditText) baseView.findViewById(R.id.et_csrq);
		et_xingming = (EditText) baseView.findViewById(R.id.et_xingming);
		et_xftz = (EditText) baseView.findViewById(R.id.et_xftz);
		et_bi = (EditText) baseView.findViewById(R.id.et_bi);
		et_rwg = (EditText) baseView.findViewById(R.id.et_rwg);
		et_jz = (EditText) baseView.findViewById(R.id.et_jz);
		et_kq = (EditText) baseView.findViewById(R.id.et_kq);
		et_szhdd = (EditText) baseView.findViewById(R.id.et_szhdd);
		et_jbbk = (EditText) baseView.findViewById(R.id.et_jbbk);

		et_sfyjx = (EditText) baseView.findViewById(R.id.et_sfyjx);
		etw_xcsfrq.setAfter(true,0);
	}


	/**
	 * 设置与管理卡共享数据相关
	 *
	 * @author 王婷婷
	 * @date 2018年1月10日 下午4:41:44
	 */
	public static void setFatherMatherData( ) {
		List<CHILD_BASEINFO> acs = fdbmanger.findAllByWhere(CHILD_BASEINFO.class,
				"IDCARD = '" + userInfo.getIDCARD() + "'");
		if (acs.size() > 0) {
			CHILD_BASEINFO baseInfo = acs.get(acs.size() - 1);
			et_fqxm.setText(baseInfo.getFARTHERNAME());
			et_fqlxdh.setText(baseInfo.getFATHERPHONE());
			et_mqxm.setText(baseInfo.getMOTHERNAME());
			et_mqlxdh.setText(baseInfo.getMOTHERPHONE());
		}
	}
}